package com.qf.smsplatform.interfaces.config;

import com.qf.smsplatform.common.constants.RabbitMQConstants;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.qf.smsplatform.common.constants.RabbitMQConstants.*;

/**
 * @Author: LeeRui
 * 2021/1/27 下午 7:54
 **/
@Configuration
public class RabbitConfig {


    // 交换机
    @Bean
    public Exchange preSendExchange(){
        return ExchangeBuilder.topicExchange(RabbitMQConstants.TOPIC_PRE_SEND + "_exchange").build();
    }

    // 队列
    @Bean
    public Queue preSendQueue(){
        return QueueBuilder.durable(RabbitMQConstants.TOPIC_PRE_SEND).build();
    }

    // 绑定
    @Bean
    public Binding preSendBinding(Queue preSendQueue,Exchange preSendExchange){
        return BindingBuilder.bind(preSendQueue).to(preSendExchange).with("#").noargs();
    }


}
